// By buya

int req_members = 3;

int getAmountInMap(Players@ players, Map@ map){
    int count = 0;
    for(int i=0; i<players.getAmount(); i++)
        if(players[i].getMap().getID() == map.getID() && players[i].getChannel().getID() == map.getChannel().getID())
            count++;
    return count;
}

bool checkLevels(Players@ players, int minlevel, int maxlevel){
    for(int i=0; i<players.getAmount(); i++)
        if(players[i].getLevel() < minlevel || players[i].getLevel() > maxlevel)
            return false;
    return true;
}

void npc(Player @player, NPC @npc) {
	int state = npc.getState();
	int map = player.getMap().getID();
	if (map == 100000200){
    		if(state == 0){
        		if(@player.getParty() == 0 || player.getParty().getLeader() != player.getID()){
            			npc.addText("This is the #rPrimrose Hill#k. When there is a full moon the moon bunny comes to make rice cakes. Growlie wants rice cakes so you better go help him or he'll eat you. (YOU MUST HAVE A PARTY OF 3+!)");
            			npc.sendNext();
            			npc.end();
        		}
        		else{
            			Players @members = player.getParty().getMembers();
            			if(getAmountInMap(members, player.getMap()) < req_members || members.getAmount() < req_members){
                			npc.addText("Your party is not a party of three. Make sure all your members are present and qualified to participate in this quest.");
                			npc.sendNext();
                                        npc.end();
            			}
            			else if(!checkLevels(members, 10, 200)){
                			npc.addText("Someone in your party does not have the right level ~ please check again");
                			npc.sendNext();
                                        npc.end();
            			}
            			else if(!player.getChannel().createEvent("henesyspq", player.getParty())){
                			npc.addText("Some other party has already gotten in to try clearing the quest. Please try again later.");
                			npc.sendNext();
                                        npc.end();
            			}
			}
		}
	}
  	else if(map == 910010400){
     			player.changeMap(100000200);
     			npc.end();
	}
	else if(map == 910010100){
    			player.changeMap(100000200);
    			npc.end();
  	}
}